package com.example.toolproject.demo.controller;

import com.example.toolproject.demo.domain.Role;
import com.example.toolproject.demo.service.RoleService;
import com.example.toolproject.demo.util.ResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @ClassName RoleController
 * @Description TODO
 * @Author lvyongwei
 * @Date 2020-07-07 10:53
 **/
@Controller
@CrossOrigin
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    /**
     * 获取到角色信息
     * @return
     */
    @GetMapping("/getAllRole")
    @ResponseBody
    public ResultBean getAllRole(){
        try{
            List<Role> roleList=roleService.getAllRole();
            return ResultBean.success("获取到角色信息成功",roleList);
        }catch(Exception e){
            return ResultBean.error("没有获取到角色信息");
        }
    }
}
